from django.db import models
from django.contrib.auth.models import AbstractUser


# Create your models here.

class Users(AbstractUser):
    mobile = models.CharField(max_length=11, verbose_name='手机号')

    class Meta:
        db_table = 'users'

    def __str__(self):
        return self.username


class Addr(models.Model):
    # 收件人
    receiver = models.CharField("收件人", max_length=30)
    receive_mobile = models.CharField("手机号", max_length=11)
    receive_addr = models.CharField("收货地址", max_length=100)
    is_default = models.BooleanField("是否默认", default=False)
    user = models.ForeignKey(Users, on_delete=models.CASCADE, verbose_name="用户")

    def __str__(self):
        return self.receiver + " " + self.receive_mobile + " " + self.receive_addr

    class Meta:
        db_table = "addr_t"
        verbose_name = "收货地址表"
        verbose_name_plural = verbose_name
